
package cn.tang.tframe.dubbox.filter;

import com.alibaba.dubbo.common.Constants;
import com.alibaba.dubbo.common.extension.Activate;
import com.alibaba.dubbo.rpc.Filter;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Result;
import com.alibaba.dubbo.rpc.RpcException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * Created by tanghc on 2016/4/7.
 */
@Activate(group = Constants.CONSUMER)
public class MonitorConsumerFilter implements Filter {

	Logger logger = LoggerFactory.getLogger(this.getClass());

	// JsonMapper jsonMapper = new JsonMapper();
	public Result invoke(Invoker<?> invoker, Invocation inv)
		throws RpcException {
		logger.debug("========== monitor ====  dubbo consumer  ==========");
		Map<String, String> attachments = inv.getAttachments();
		logger.debug("ConsumerFilter set request to attach");
		// if(null != attachments && null !=
		// RequestContextAttributeHolder.getRequestAttributes()){
		// attachments.put("requestInfo",
		// jsonMapper.toJson(RequestContextAttributeHolder.getRequestAttributes()));
		// }
		return invoker.invoke(inv);
	}

}
